﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace SqlMon
{
    public class SqlMonInterface:MarshalByRefObject
    {
        Queue<string> sqlQueue = MainForm.sqlQueue;

        public void IsInstalled(Int32 inClientPID)
        {
            lock(sqlQueue)
                sqlQueue.Enqueue(string.Format("SqlMon已经成功安装到进程{0}中",inClientPID));
        }

        public void ReportException(Exception ex)
        {
            lock (sqlQueue)
                sqlQueue.Enqueue(string.Format("出现程序异常:{0}", ex.Message));
        }

        public void OnPrepare(Int32 InClientPID, String[] InFileNames)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < InFileNames.Length; i++)
            {
                sb.Append(InFileNames[i] + Environment.NewLine);
            }

            lock (sqlQueue)
                sqlQueue.Enqueue("进程ID:[" + InClientPID + "]"+ Environment.NewLine + sb.ToString());
        }
    }
}
